package io.terminus.spzx.manager.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.terminus.spzx.manager.service.FileUploadService;
import io.terminus.spzx.model.vo.common.Result;
import io.terminus.spzx.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author lichunlong lcl253137@alibaba-inc.com
 * @Desc 文件上传Controller
 * @Date 2024-05-26
 */
@RestController
@Tag(name = "文件上传接口")
@RequestMapping(value = "/admin/system")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    @PostMapping("/fileUpload")
    public Result<String> fileUpload(@RequestParam("file") MultipartFile uploadFile) {
        String fileUrl = fileUploadService.fileUpload(uploadFile);

        return Result.build(fileUrl, ResultCodeEnum.SUCCESS);
    }

}
